import Vue from 'vue'
import Router from 'vue-router'
import versionUpdate from '@/update/versionUpdate.js';
Vue.use(Router)

var router = new Router({
  routes: [
    {
      path: '/',
      redirect: { name: 'Login' }
    },
    {
      path: '/login',
      name: 'Login',
      component: () => import('@/pages/login')
    },
    {
      path: "/stopPaymentBulk",
      name: "stopPaymentBulk",
      component: () => import('@/pages/stopPaymentBulk')
    },
    {
      path: '/auditImport',
      name: 'auditImport',
      component: () => import('@/pages/auditImport')
    },
    {
      path: '/userManagement',
      name: 'userManagement',
      component: () => import('@/pages/userManagement')
    },
    {
      path: '/billInfoList',
      name: 'billInfoList',
      component: () => import('@/pages/billInfoList')
    },
    {
      path: '/billInfo',
      name: 'billInfo',
      component: () => import('@/pages/billInfo')
    },
    {
      path: '/register',
      name: 'Register',
      component: () => import('@/pages/register')
    },
    {
      path: '/forgetPassword',
      name: 'ForgetPassword',
      component: () => import('@/pages/forgetPassword')
    },
    {
      path: '/homePage',
      name: 'HomePage',
      component: () => import('@/pages/homePage')
    },

    {
      path: '/accountSetting',
      name: 'AccountSetting',
      component: () => import('@/pages/accountSetting')
    },
    // {
    //   path: '/addArea',
    //   name: 'AddArea',
    //   component: () => import('@/pages/addArea')
    // },
    {
      path: '/addIndividual',
      name: 'AddIndividual',
      component: () => import('@/pages/addIndividual')
    },
    {
      path: '/addEmployee',
      name: 'AddEmployee',
      component: () => import('@/pages/addEmployee')
    },
    {
      path: '/billList',
      name: 'BillList',
      component: () => import('@/pages/billList')
    },
    {
      path: '/billManagement',
      name: 'BillManagement',
      component: () => import('@/pages/billManagement')
    },
    {
      path: '/businessManagement',
      name: 'BusinessManagement',
      component: () => import('@/pages/businessManagement')
    },
    {
      path: '/employeeList',
      name: 'EmployeeList',
      component: () => import('@/pages/employeeList')
    },
    // {
    //   path: '/fiveFund',
    //   name: 'FiveFund',
    //   component: () => import('@/pages/fiveFund')
    // },
    // {
    //   path: '/outsourcing',
    //   name: 'Outsourcing',
    //   component: () => import('@/pages/outsourcing')
    // },
    // {
    //   path: '/paymentSchedule',
    //   name: 'PaymentSchedule',
    //   component: () => import('@/pages/paymentSchedule')
    // },
    {
      path: '/invoiceManagement',
      name: 'InvoiceManagement',
      component: () => import('@/pages/invoiceManagement')
    },
    // {
    //   path: '/companySetting',
    //   name: 'CompanySetting',
    //   component: () => import('@/pages/companySetting')
    // },
    {
      path: '/inputData',
      name: 'InputData',
      component: () => import('@/pages/inputData')
    },
    // {
    //   path: '/orgStructure',
    //   name: 'OrgStructure',
    //   component: () => import('@/pages/orgStructure')
    // },
    // {
    //   path: '/changeRecord',
    //   name: 'ChangeRecord',
    //   component: () => import('@/pages/changeRecord')
    // },
    // {
    //   path: '/personnelChange',
    //   name: 'PersonnelChange',
    //   component: () => import('@/pages/personnelChange')
    // },
    // {
    //   path: '/history',
    //   name: 'History',
    //   component: () => import('@/pages/history')
    // },
    // {
    //   path: '/fiveFundDetail',
    //   name: 'FiveFundDetail',
    //   component: () => import('@/pages/fiveFundDetail')
    // },
    // {
    //   path: '/paymentScheduleDetail',
    //   name: 'PaymentScheduleDetail',
    //   component: () => import('@/pages/paymentScheduleDetail')
    // },
    {
      path: '/moreFunctions',
      name: 'MoreFunctions',
      component: () => import('@/pages/moreFunctions')
    },
    {
      path: '/completeInfo',
      name: 'CompleteInfo',
      component: () => import('@/pages/completeInfo')
    },
    {
      path: '/completeInfoDetail',
      name: 'CompleteInfoDetail',
      component: () => import('@/pages/completeInfoDetail')
    },

    {
      path: '/personageManagement',
      name: 'PersonageManagement',
      component: () => import('@/pages/personageManagement')
    },
    {
      path: '/addCompany',
      name: 'AddCompany',
      component: () => import('@/pages/addCompany')
    },
    {
      path: '/editCompany',
      name: 'EditCompany',
      component: () => import('@/pages/editCompany')
    },
    {
      path: '/employeesList',
      name: 'EmployeesList',
      component: () => import('@/pages/employeesList')
    },
    {
      path: '/employeesDetail',
      name: 'EmployeesDetail',
      component: () => import('@/pages/employeesDetail')
    },
    // {
    //   path: '/personnelDetail',
    //   name: 'PersonnelDetail',
    //   component: () => import('@/pages/personnelDetail')
    // },
    {
      path: '/personalInfo',
      name: 'PersonalInfo',
      component: () => import('@/pages/personalInfo')
    },
    {
      path: '/auditList',
      name: 'AuditList',
      component: () => import('@/pages/auditList')
    },
    {
      path: '/auditCompany',
      name: 'AuditCompany',
      component: () => import('@/pages/auditCompany')
    },
    // {
    //   path: '/paymentSchedules',
    //   name: 'PaymentSchedules',
    //   component: () => import('@/pages/paymentSchedules')
    // },
    {
      path: '/auditDetail',
      name: 'AuditDetail',
      component: () => import('@/pages/auditDetail')
    },
    {
      path: '/auditCompanyDetail',
      name: 'AuditCompanyDetail',
      component: () => import('@/pages/auditCompanyDetail')
    },
    {
      path: '/payZone',
      name: 'PayZone',
      component: () => import('@/pages/payZone')
    },
    {
      path: '/payZoneList',
      name: 'PayZoneList',
      component: () => import('@/pages/payZoneList')
    },
    {
      path: '/auditMessageList',
      name: 'AuditMessageList',
      component: () => import('@/pages/auditMessageList')
    },
    {
      path: '/payManagement',
      name: "PayManagement",
      component: () => import('@/pages/payManagement')
    },
    {
      path: '/payTheProject',
      name: "PayTheProject",
      component: () => import('@/pages/payTheProject')
    },
    {
      path: "/employeeContributions",
      name: "EmployeeContributions",
      component: () => import('@/pages/employeeContributions')
    },
    {
      path: "/orderTypeManagement",
      name: "OrderTypeManagement",
      component: () => import('@/pages/orderTypeManagement')
    },
    {
      path: "/balanceManagement",
      name: "BalanceManagement",
      component: () => import('@/pages/balanceManagement')
    },
    {
      path: "/balanceDetail",
      name: "BalanceDetail",
      component: () => import('@/pages/balanceDetail')
    },
    {
      path: "/contractManagement",
      name: "ContractManagement",
      component: () => import('@/pages/contractManagement')
    },
    {
      path: "/balanceList",
      name: "BalanceList",
      component: () => import('@/pages/balanceList')
    },
    {
      path: "/editIndividual",
      name: "EditIndividual",
      component: () => import('@/pages/editIndividual')
    },
    {
      path: "/billDetail",
      name: "BillDetail",
      component: () => import('@/pages/billDetail')
    },
    {
      path: "/platformManagement",
      name: "PlatformManagement",
      component: () => import('@/pages/platformManagement')
    },
    {
      path:"/collectionSchedule",
      name:"CollectionSchedule",
      component: () => import('@/pages/collectionSchedule')
    },
  ]
});

router.beforeEach((to, from, next) => {
  /** 判断当前代码版本是否与服务器中代码版本一致，如不一致则刷新页面获取最新*/
  versionUpdate.isNewVersion();
  if (to.name == 'ForgetPassword' || to.name == 'Register') {
    next();
  } else if (to.name != 'Login' && !sessionStorage.getItem('login')) {
    next('/login');
  } else {
    next();
  }
})
export default router;
